# 初始化app
from flask import Flask
from setting import map_config

# 负责创建APP
def creat_app(config_type):
    app = Flask(__name__)
    # 加载项目配置
    app.config.from_object(map_config.get(config_type))

    # 初始化限流器
    from comment.utils.limiter import limiter as lmt
    # 绑定到app初始化中
    lmt.init_app(app)

    # 初始化redis
    from comment.utils.shopping_redis import redis_client
    redis_client.init_app(app)


    # 加载日志处理工具
    from comment.utils.logger import create_logger
    create_logger(app)

    # 初始化SQLAlchemy
    from comment.models import db
    db.init_app(app)

    # 加载模块的蓝图
    from Shopping.resource.user import user_bp
    app.register_blueprint(user_bp)




    return app
